package com.zxk.weixinpay.mapper;

import com.zxk.weixinpay.domain.Video;
import com.zxk.weixinpay.provider.VideoProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface VideoMapper {

    @Select("select * from video")
//    @Results({
//            @Result(column = "cover_img",property = "coverImg"), //javaType = java.util.Date.class
//            @Result(column = "view_num",property = "viewNum")
//    })
    List<Video> findAll();

    @Select("select * from video where id = #{id}")
    Video findByid(Integer id);

//    @Update("update video set title = #{title} where id = #{id}")
    @UpdateProvider(type = VideoProvider.class,method = "updateVideo")
    int update(Video video);


    @Delete("delete from video where id  = #{id}")
    int del(Integer id);

    @Insert("INSERT INTO `video` (  `title`, `summary`, `cover_img`, `view_num`, `price`, `online`, `point` )" +
            "VALUES" +
            "(  #{title},  #{summary},  #{coverImg}, #{viewNum},  #{price}, #{online},  #{point} )")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    int save(Video video);
}
